/**
 * Created by huangxiaolu on 2014/4/11.
 */
var http = require('http');
var options = {
    port: 8000,
    hostname: '127.0.0.1',
    method: 'CONNECT',
    path: 'www.bing.com:80'
};

var req = http.request(options);
req.end();

req.on('connect', function(res, socket, head) {
    console.log('got connected!');

    // make a request over an HTTP tunnel
    socket.write('GET / HTTP/1.1\r\n' +
        'Host: www.bing.com:80\r\n' +
        'Connection: close\r\n' +
        '\r\n');
    socket.on('data', function(chunk) {
        console.log(chunk.toString());
    });
   /* socket.on('end', function() {
        proxy.close();
    });*/
});